import { http } from "@/utils/http";
import { baseUrlApi } from "./utils";

// 入住单相关类型定义
export interface Customer {
  name: string;
  idCard: string;
  phone: string;
}

export interface Bill {
  rate: number;
  deposit: number;
  total: number;
}

export interface CheckInSubOrder {
  checkInDate: string | null;
  checkOutDate: string | null;
  room: {
    roomId: number;
    roomTypeId: number;
    roomNumber: string;
  };
  customers: Customer[];
  bill: Bill;
}

export interface CheckInOrder {
  status: string;
  totalAmount: number;
  subOrders: CheckInSubOrder[];
}

export const startCheckIn = (checkInOrderDTO: CheckInOrder) => {
  return http.request<any>("post", baseUrlApi("check-in/start-check-in"), {
    data: checkInOrderDTO
  });
};

export const updateCheckIn = (checkInOrderDto: CheckInOrder) => {
  return http.request<any>("post", baseUrlApi("check-in/update"), {
    data: checkInOrderDto
  });
};

export const refreshCheckIn = () => {
  return http.request<any>("get", baseUrlApi(`check-in/refresh`));
};

export const terminateCheckIn = () => {
  return http.request<any>("post", baseUrlApi(`check-in/terminate-check-in`));
};

export const createCheckInPayment = () => {
  return http.request<any>("post", baseUrlApi(`check-in/create-payment`));
};
